<?php


namespace Xiaoguai\DesignPattern\DP012;


use Xiaoguai\DesignPattern\DP012\Flyweight\Flyweight;

class FlyweightFactory
{
    protected $map = [];

    public function getFlyweight(string $key): FlyweightInterface
    {
        if (!isset($this->map[$key])) {
            $this->map[$key] = new Flyweight($key);
        }
        return $this->map[$key];
    }
}